//
//  ByItemViewModel.m
//  jmsfhz_ios
//
//  Created by pro on 16/8/4.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ByItemViewModel.h"

#import "ByNetItemApi.h"

@implementation ByItemViewModel

- (void)itemQuery:(ByNetParamsModel *)params {
    
    void (^failure)(ByNetBaseResult *result) = nil;
    
    if([self.itemDelegate respondsToSelector:@selector(itemQueryFailure:)]) {
        
        failure = ^(ByNetBaseResult *result){
            [self.itemDelegate itemQueryFailure:result];
        };
    }
    
    [ByNetItemApi itemQuery:params success:^(ByNetBaseResult *result) {
        if (self.itemDelegate) {
            [self.itemDelegate itemQuerySuccess:result];
        }
    } failure:failure];
}


- (void)itemSend:(ByNetParamsModel *)params {
    
    void (^failure)(ByNetBaseResult *result) = nil;
    
    if([self.itemSendDelegate respondsToSelector:@selector(itemSendFailure:)]) {
        
        failure = ^(ByNetBaseResult *result){
            [self.itemSendDelegate itemSendFailure:result];
        };
    }
    
    [ByNetItemApi itemSend:params success:^(ByNetBaseResult *result) {
        if (self.itemSendDelegate) {
            [self.itemSendDelegate itemSendSuccess:result];
        }
    } failure:failure];
}

@end
